<?php
	class ControllerPageDetail extends Controller
	{
		public function index()
		{
			$this->load->model("core/sitemap");
			
			$siteid = $this->user->getSiteId();
			
			$this->document->sitemapid = $this->request->get['sitemapid'];

			$this->data['breadcrumb'] = $this->model_core_sitemap->getBreadcrumb($this->document->sitemapid, $siteid, -1);
			
			if($this->document->sitemapid != "")
			{
				$sitemap = $this->model_core_sitemap->getItem($this->document->sitemapid, $siteid);
				
				$this->data['breadcrumb'] = $sitemap['sitemapname'];
			
				switch($sitemap['moduleid'])
				{
					case "":
						$this->data['breadcrumb'] = "Search result with keyword \"".$this->request->get['keyword']."\"";
						$this->data['module'] = $this->loadModule('module/searchresult');
						break;
					case "module/information":
						$this->data['module'] = $this->loadModule('module/information');
						break;
					case "module/news":
						$this->data['module'] = $this->loadModule('module/news');
						break;
					case "module/contact":
						$this->data['module'] = $this->loadModule('module/contact');
						break;
					case "module/product":
						$this->data['module'] = $this->loadModule('product/product');
						break;
					case "custom":
						if($this->document->sitemapid == 'site3')
						{
							//Goi gio hang
							$this->data['module'] = $this->loadModule('product/cart');
						}
						if($this->document->sitemapid == 'site2')
						{
							$this->data['module'] = $this->loadModule('product/product');
						}
						break;
					
				}
				/*switch($this->request->get['module'])
				{
					case "products":
						$this->data['module'] = $this->loadModule('product/product');
						break;
				}*/
			}
			
			$this->id="content";
			$this->template="page/detail.tpl";
			$this->layout="layout/home";
			
			$this->children = array(
				'module_search' => 'module/search',
				'module_danhmucsanpham' => 'module/danhmucsanpham',
				'module_supportonline' => 'module/supportonline',
				'module_hotproduct' => 'module/hotproduct',
				'module_adv' => 'module/adv',
				'module_lienket' => 'module/lienket',
				'module_doitac' => 'module/doitac',
				'module_thongketruycap' => 'module/thongketruycap'			
			);
			$this->render();
		}
	}
?>